package com.atldy.commerce.controller;

import com.atldy.commerce.service.NacosClientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @version 1.0
 * @Author: lidongyang
 * @CreateTime: 2021-07-31 18:56
 * @Description：
 */
@Slf4j
@RestController
public class NacosClientController {

    private final NacosClientService nacosClientService;


    public NacosClientController(NacosClientService nacosClientService) {
        this.nacosClientService = nacosClientService;
    }

    @GetMapping("/getServiceInstance")
    public List<ServiceInstance> getServiceInstance(@RequestParam(defaultValue = "e-commerce-nacos-client") String serviceId) {
        log.info("服务名称是：{}", serviceId);
        return nacosClientService.getServiceInstance(serviceId);
    }
}